Page({
  data: {
    popupshow: false,
    //订单列表
    order_list: [],
    //当前选中的订单
    se_order: {},
  },
  onLoad: function (options) {
    //获取订单列表
    let that = this;
    new Promise((resolve: any, reject: any) => {
      tt.request({
        url: getApp().globalData.baseurl + "/douyin/query_order_list",
        data: {
          open_id: getApp().globalData.userinfo.openid,
        },
        header: {
          "content-type": "application/json",
        },
        method: "POST",
        responseType: "text",
        success(res: any) {
          if (res.data.code === 0) {
            resolve(res.data.data);
          } else {
            reject("请求报错");
          }
        },
        fail(err: any) {
          reject(err.errMsg);
        },
      });
    })
      .then((res: any) => {
        that.setData({
          order_list: res,
        });
      })
      .catch((err: any) => {
        console.log(err);
      });
  },
  //打开弹出层
  openPopup(event: any) {
    let that = this;
    let se_order: any =
      that.data.order_list[parseInt(event.currentTarget.dataset.index)];
    se_order.order_id = se_order.order_id.toString();
    that.setData({
      popupshow: true,
      se_order,
    });
  },
  //关闭弹出层
  closePro() {
    let that = this;
    that.setData({
      popupshow: false,
    });
  },
  //去评价
  goEvaluate() {
    tt.navigateTo({
      url: "/pages/evaluate/evaluate",
    });
  },
  //错误回调
  handleError(event: any) {
    const { errMsg, errNo } = event.detail;
    console.log(errMsg, errNo);
  },
  //评价按钮错误异常
  rateErr(event: any) {
    const { errMsg, errNo } = event.detail;
    console.log(errMsg, errNo);
  },
});
